package com.example.organization.service;

import com.example.event.ModuleEvent;
import com.example.model.entity.user.User;
import com.example.spi.ModuleService;
import org.springframework.stereotype.Component;

// organization-module中的服务
@Component // 让Spring管理这个Bean
public class OrgModuleService implements ModuleService {
    @Override
    public String getName() {
        return "OrgModule";
    }

    @Override
    public void execute() {
        System.out.println("组织模块服务执行...");
    }

    @Override
    public boolean supports(ModuleEvent event) {
        return event.getPayload() instanceof User;
    }

    @Override
    public void handleEvent(ModuleEvent event) {
        User user = (User) event.getPayload();
        // 更新用户组织关系
        System.out.println("组织模块更新用户: " + user.getName() + " 的组织关系");
    }
}